<template>
  <div class="exchangeOrder">
    <el-card>
      <div>
        <el-row type="flex" class="row-bg">
          <el-col :span="8">
            <label>订单编号：</label>
            <el-input v-model="searchInfo.orderId" style="width:70%" placeholder="订单编号"></el-input>
          </el-col>
          <el-col :span="8" style="padding-left:10px">
            <el-button type="primary" @click="search" style="margin-bottom:20px">查询</el-button>
          </el-col>
        </el-row>
        <label></label>
      </div>
      <avue-crud
        ref="crud"
        style="width:100%"
        :data="loadData"
        :option="tableOption"
        :table-loading="loading"
      >
        <template slot="menu" slot-scope="scope">
          <el-button type="text" icon="el-icon-view" @click="details(scope.row)">详情</el-button>
        </template>
      </avue-crud>
    </el-card>
    <template>
      <div style="width:100%;position:relative;height:100px">
        <el-pagination
          :page-sizes="[10, 20,30,40, 50, 100]"
          :pager-count="7"
          :current-page="page.current"
          :page-size="page.size"
          :total="page.total"
          layout="total, sizes, prev, pager, next, jumper"
          style="margin:2% 0;position:absolute;right:1%"
          background
          @size-change="sizeChange"
          @current-change="currentChange"
        ></el-pagination>
      </div>
    </template>
    <el-dialog title="订单详情" :visible.sync="dialogVisible" width="60%">
      <orderDetails :orderDetailsInfo="orderDetailsInfo" />
      <span slot="footer" class="dialog-footer">
        <el-button @click="handlClose">取 消</el-button>
        <el-button type="primary" @click="handlSure" :loading="loadingSure">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import orderDetails from "./orderDetails.vue";
import { integralDetailedLists } from "@/api/shop/member/list.js";

export default {
  components: {
    orderDetails,
  },
  data() {
    return {
      dialogVisible: false,
      loading: false,
      loadingSure: false,
      page: {
        total: 0,
        size: 10,
        current: 1,
      },
      searchInfo: {},
      loadData: [{ ddbh: "1212" }],
      tableOption: {
        header: false,
        align: "center",
        editBtn: false,
        delBtn: false,
        column: [
          {
            label: "订单编号",
            prop: "payOrderNo",
             minWidth:120,
            overHidden:true,
          },
          {
            label: "商品数量",
            prop: "payGoodsNum",
             minWidth:120,
            overHidden:true,
          },
          {
            label: "花费积分（个）",
            prop: "payGoodsPrice",
             minWidth:120,
            overHidden:true,
          },
          {
            label: "下单渠道",
            prop: "orderSource",
             minWidth:120,
            overHidden:true,
          },
          {
            label: "门店",
            prop: "shopName",
             minWidth:120,
            overHidden:true,
          },
          {
            label: "操作人",
            prop: "operatorId",
             minWidth:120,
            overHidden:true,
          },
          {
            label: "下单时间",
            prop: "payTime",
             minWidth:120,
            overHidden:true,
          },
        ],
      },
      orderDetailsInfo: {},
    };
  },
  methods: {
    getList() {
      integralDetailedLists(
        { personId: this.$route.query.personId,orderId:this.searchInfo.orderId},
        this.page
      ).then((val) => {
        let data = val.data.data;
        this.page = {
          total: data.total,
          size: data.size,
          current: data.current,
        };
        this.loadData = data.records;
        console.log(this.loadData);
      });
    },
    handlClose() {
      this.dialogVisible = false;
      this.$refs["ruleForm"].resetFields();
    },
    handlSure() {
      this.$refs["ruleForm"].validate((valid) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    sizeChange(size) {
      this.page.size = size;
      this.getList();
    },
    currentChange(current) {
      this.page.current = current;
      this.getList();
    },
    search() {
      this.getList();
    },
    details(item) {
      this.dialogVisible = true;
      this.orderDetailsInfo = item;
    },
  },
};
</script>

<style lang="scss" scoped>
.exchangeOrder {
  .row {
    margin: 30px 0px;
  }
  .bg {
    width: 202px;
    height: 33px;
    text-align: center;
    line-height: 33px;
    background-color: rgba(242, 242, 242, 1);
    font-weight: 400;
    font-style: normal;
    font-size: 16px;
    color: rgba(0, 0, 0, 0.647058823529412);
  }
}
</style>